package com.qf.dao.impl;

import com.qf.dao.CustagDao;

import com.qf.pojo.Custag;
import com.qf.utils.DataSourceUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CustagDaoImpl implements CustagDao {
    QueryRunner qr =new QueryRunner(DataSourceUtil.getDataSource());
    @Override
    public Custag findTagType(int tagId) {
        String sql="select * from cus_tag where tag_id=?";
        try {
            return qr.query(sql,new BeanHandler<>(Custag.class),tagId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }



    @Override
    public List<Custag> findCustag() {
        String sql="select * from cus_tag";
        try {
             return qr.query(sql,new BeanListHandler<>(Custag.class));
        } catch (SQLException e) {

            e.printStackTrace();
        }
        return null;
    }
}
